package com.hualan.controller;

import com.hualan.domain.LevelAndGood;
import com.hualan.domain.Teacher;
import com.hualan.domain.TeacherAndGood;
import com.hualan.domain.Teacherlevel;
import com.hualan.service.TeacherGoodService;
import com.hualan.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/teachergood")
public class TeacherGoodController {
    @Autowired
    public TeacherGoodService teacherGoodService;

    @GetMapping("/selectTeacherGood")
    public R selectTeacherByGoodname(int id){
        List<TeacherAndGood> teacherList = teacherGoodService.selectTeacherByGoodname(id);
        if (teacherList.size()>0){
            return R.success(teacherList);
        }else {
            return R.fail(teacherList);
        }
    }

    @GetMapping("/selectTeacherByLevelGood")
    public R selectTeacherByLevelGood(String level,String good){
        List<Teacher> levelAndGoodList= teacherGoodService.selectTeacherByLevelGood(level,good);
        if (levelAndGoodList.size()>0){
            return R.success(levelAndGoodList);
        }else {
            return R.fail(levelAndGoodList);
        }
    }

    @GetMapping("/selectTeacherByLevelGoodAddress")
    public R selectTeacherByLevelGoodAddress(String level,String good, String address){
        System.out.println("后端接收数据" + level + good + address);
        List<Teacher> teachers = teacherGoodService.selectTeacherByLevelGoodAddress(level, good, address);
        if (teachers.size()>0){
            return R.success(teachers);
        }else {
            return R.fail(teachers);
        }
    }
}
